<html>
<head>
<title>khutro.net</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="css/userpage.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
em {
	color: #999;
}

#contentmain .container2 .logincontent .logincontentmain h3 {
	color: #040406;
}
-->
</style>

</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0"
	marginheight="0">
	<script src="//connect.facebook.net/en_US/all.js"></script>
	<!-- Save for Web Slices (khutroslide.psd) -->
	<div id="header">
		<div id="headerContent">
			<a href="index.action" id="logo">khutro</a>
			<ul id="menuBar">
				<li><a href="index.action">Trang Chủ</a>
				</li>
				<li><a href="help.action">Trợ Giúp</a>
				</li>
				<li><a href="user.action">Trang Cá Nhân</a>
				</li>
				<li><a class="upload" href="addnews.action">Đăng Tin</a>
				</li>
			</ul>
			<div id="loginPanel">
				<a class="loginButton" href="login.action">Đăng Nhập</a>
			</div>
		</div>
	</div>
	<img src="images/spacer.gif" width="1" height="56" alt="">


	<div id="contentmain">
		<div class="logincontent">
			<h3>Đăng nhập</h3>
			<div id="checkingStatus" style="display: block">
				<h4>
					<img src="images/loading.gif" /> Đang kiểm tra kết nối của bạn với
					Facebook. Ấn F5 nếu thực hiện quá lâu...
				</h4>
			</div>
			<div id="loginContainer" style="display: none;">
				<h4>Click vào nút dưới đây để đăng nhập với tài khoản Facebook
					của bạn:</h4>
				<div id="fb-root"></div>
				<script>
					(function(d, s, id) {
						var js, fjs = d.getElementsByTagName(s)[0];
						if (d.getElementById(id))
							return;
						js = d.createElement(s);
						js.id = id;
						js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=418620964854308";
						fjs.parentNode.insertBefore(js, fjs);
					}(document, 'script', 'facebook-jssdk'));
				</script>
				<div class="fb-login-button" data-scope="email,publish_actions"></div>
			</div>
		</div>
		<s:form action="adduser.action" id="loginForm" method="post">
			<input type="hidden" name="signedRequest" id="signedRequest" />
			<input type="hidden" name="accessToken" id="accessToken" />
			<input type="hidden" name="email" id="email" />
			<input type="hidden" name="displayName" id="displayName" />
			<input type="hidden" name="avatar" id="avatar" />
		</s:form>
		<script type="text/javascript">
			function getinfo() {
				//-----------------------Random-------
				FB.api('/me', function(response) {
					var email = response.email;
					var displayName = response.name;
					var avatar = 'https://graph.facebook.com/' + response.id
							+ '/picture?type=normal';
					document.getElementById("email").value = email;
					document.getElementById("displayName").value = displayName;
					document.getElementById("avatar").value = avatar;
					document.loginForm.submit();
				});
				//
			}
		</script>
		<script type="text/javascript">
			window.fbAsyncInit = function() {
				FB.init({
					appId : '418620964854308',
					status : true,
					cookie : true,
					xfbml : true
				});

				FB
						.getLoginStatus(function(response) {
							if (response.status === 'connected') {
								submitToken(response);
								getinfo();
							} else {
								FB.login(function(response) {
									// handle the response
								}, {
									scope : 'email,publish_actions'
								});
								//document.getElementById('loginContainer').innerHTML = ('<img id="loginBtn" onclick="FB.login(function(response) {}, {scope: \'email,publish_actions\'});" style="cursor: pointer;" src="images/facebook_signin.png">');
								document.getElementById('checkingStatus').style.display = 'none';
								document.getElementById('loginContainer').style.display = 'block';
							}
						});

				FB.Event.subscribe('auth.authResponseChange',
						function(response) {
							if (response.authResponse) {
								submitToken(response);
							}
						});
			};

			var submited = false;

			function submitToken(response) {
				if (submited)
					return;
				submited = true;
				getinfo();
			}
		</script>


	</div>
	<div id="footercus"
		style="text-align: center; color: #FFF; background: #CCC">
		<em>Designed by FU team | Powered by Struts<br> khutro.net</em>

	</div>


	<!-- End Save for Web Slices -->
</body>
</html>